package com.qf.emp.controller;

import com.qf.emp.service.EmpService;
import com.qf.emp.service.Impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "removeEmpController", value = "/manager/safe/removeEmpController")
public class RemoveEmpController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//       通过包装类获取URL指定的类型参数
        Integer id = Integer.valueOf(request.getParameter("id"));
//        获取对应的sql 方法
        EmpService empService = new EmpServiceImpl();
//        调用方法
        empService.removeEmp(id);
//        完成跳转（跳转至获取数据的方法路劲下）
        response.sendRedirect(request.getContextPath() + "/manager/safe/showallEmpController");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
